package exception;

/**
 * 异常的抛出
 */
public class ThrowDemo {
    public static void main(String[] args) {//很少往main里抛，抛给main，jvm杀死程序
        Student zs = new Student();
        try {
            zs.setAge(2000);
        } catch (IllegalAgeException e) {
            e.printStackTrace();//打印错误堆栈跟踪信息
            System.out.println(e.getMessage());//获取错误信息并输出
        }
        System.out.println("此人的年龄为" + zs.getAge() + "岁");
    }
}
